﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using Microsoft.Web.WebSockets;
using FServer.Models;

namespace FServer.Controllers
{
    [HttpHeader("Access-Control-Allow-Origin", "*")]
    public class TVBookController : ApiController
    {
        public HttpResponseMessage Get()
        {
            HttpContext.Current.AcceptWebSocketRequest(
                new WSHandler()
            );
            return new HttpResponseMessage(
                HttpStatusCode.SwitchingProtocols
            );
        }

        public object[] PostDangKy(NguoiDung nguoiDung)
        {
            NguoiDungDAO dao = new NguoiDungDAO();
            try
            {
                dao.themNguoiDung(nguoiDung);
                object[] obj = new object[2];
                obj[0] = "success";
                obj[1] = nguoiDung;
                return obj;
            }
            catch (Exception ex)
            {
                object[] obj = new object[1];
                obj[0] = "failed";
                return obj;
            }
        }
    }
}
